package com.benio.ycfdisplayer.fresco.photoview;

import android.view.View;
import android.widget.ImageView;

import com.benio.ycfdisplayer.displayer.ImageViewTarget;
import com.benio.ycfdisplayer.displayer.Target;
import com.benio.ycfdisplayer.displayer.TargetFactory;
import com.benio.ycfdisplayer.fresco.DraweeViewTarget;
import com.benio.ycfdisplayer.fresco.FrescoTarget;
import com.benio.ycfdisplayer.fresco.FrescoView;
import com.facebook.drawee.view.DraweeView;

/**
 * An implement of {@link TargetFactory} that supported by {@link com.benio.ycfdisplayer.fresco.photoview.PhotoViewExecutor}
 * Created by zhangzhibin on 2016/11/2.
 */
public class TargetBuilder implements TargetFactory {

    public Target build(View view) {
        if (view instanceof DraweeView) {
            return new DraweeViewTarget((DraweeView) view);
        } else if (view instanceof FrescoPhotoViewSupport) {
            return new PhotoViewTarget((FrescoPhotoViewSupport) view);
        } else if (view instanceof FrescoView) {
            return new FrescoTarget(view);
        } else if (view instanceof ImageView) {
            return new ImageViewTarget((ImageView) view);
        } else {
            throw new IllegalArgumentException("Please check you're using a proper view.");
        }
    }
}
